import {
	defineStore
} from 'pinia';

export const carStore = defineStore('carStore', {
	state: () => {
		return {
			carList: []
		};
	},
	// 也可以这样定义
	// state: () => ({ count: 0 })
	actions: {
		addCar(goods){
			const index = this.carList.findIndex(item => goods.goodsId == item.goodsId)
			if(index > -1){
				this.carList.splice(index,1);
			}
			this.carList.push(goods)
		}
	},
});